/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.govProcure.db.impl;

import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.template.SqlMapDaoTemplate;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.yunhoo.govProcure.db.dao.ProcureExecEditDao;
import com.yunhoo.govProcure.model.CateDataModel;
import com.yunhoo.govProcure.model.CateEditBase;
import com.yunhoo.govProcure.model.CateEditDetail;
import com.yunhoo.govProcure.model.ExecuteAppend;
import com.yunhoo.sys.db.util.DbTool;
import com.yunhoo.sys.util.common.LoginParam;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class ProcureExecEditDaoImpl extends SqlMapDaoTemplate implements ProcureExecEditDao {

    private static SqlMapClient sqlmap;
    private String nameSpace = "procureExec.";

    public ProcureExecEditDaoImpl(DaoManager daoManager) {
        super(daoManager);
        sqlmap = sqlmap = DbTool.getSqlMapClient();
    }

    @Override
    public List<String> queryAllCategroyStandardCode() {
        System.out.println(nameSpace + "queryAllCategroyStandardCode");
        try {
            String orgCode = LoginParam.getOrg().getCode();
            return sqlmap.queryForList(nameSpace + "queryAllCategroyStandardCode",orgCode);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public List<CateDataModel> queryCategroyStandardByCategoryCode(String categoryCode) {
        System.out.println(nameSpace + "queryCategroyStandardByCategoryCode");
        try {
            Map map = new HashMap();
            map.put("orgCode",LoginParam.getOrg().getCode());
            map.put("cateCode",categoryCode);
            return sqlmap.queryForList(nameSpace + "queryCategroyStandardByCategoryCode", map);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public CateEditBase queryCateBase(CateEditBase param) {
        System.out.println(nameSpace + "queryCateBase");
        try {
            return (CateEditBase) sqlmap.queryForObject(nameSpace + "queryCateBase", param);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public CateEditBase queryCateBaseByNumber(CateEditBase param) {
        System.out.println(nameSpace + "queryCateBaseByNumber");
        try {
            return (CateEditBase) sqlmap.queryForObject(nameSpace + "queryCateBaseByNumber", param);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public ExecuteAppend queryExecuteAppend(ExecuteAppend param) {
        System.out.println(nameSpace + "queryExecuteAppend");
        try {
            return (ExecuteAppend) sqlmap.queryForObject(nameSpace + "queryExecuteAppend", param);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public List<CateEditBase> queryListCateBase(CateEditBase param) {
        System.out.println(nameSpace + "queryListCateBase");
        try {
            return sqlmap.queryForList(nameSpace + "queryListCateBase", param);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public List<CateEditDetail> queryListCateDetailByNumber(CateEditDetail param) {
        System.out.println(nameSpace + "queryListCateDetailByNumber");
        try {
            return sqlmap.queryForList(nameSpace + "queryListCateDetailByNumber", param);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public List<CateEditDetail> queryListCateDetailForCheck(CateEditDetail param) {
        System.out.println(nameSpace + "queryListCateDetailForCheck");
        try {
            return sqlmap.queryForList(nameSpace + "queryListCateDetailForCheck", param);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public void insertExecBase(CateEditBase param) throws SQLException {
        System.out.println(nameSpace + "insertExecBase");
        sqlmap.insert(nameSpace + "insertExecBase", param);
    }

    @Override
    public void insertExecDetail(CateEditDetail param) throws SQLException {
        System.out.println(nameSpace + "insertExecDetail");
        sqlmap.insert(nameSpace + "insertExecDetail", param);
    }

    @Override
    public void insertExecuteAppend(ExecuteAppend param) throws SQLException {
        System.out.println(nameSpace + "insertExecuteAppend");
        sqlmap.insert(nameSpace + "insertExecuteAppend", param);
    }

//    @Override
//    public void updateExecBase(CateEditBase param) throws SQLException {
//        System.out.println(nameSpace + "updateExecBase");
//        sqlmap.delete(nameSpace + "updateExecBase", param);
//    }
    @Override
    public void updateExecDetail(CateEditDetail param) throws SQLException {
        System.out.println(nameSpace + "updateExecDetail");
        sqlmap.update(nameSpace + "updateExecDetail", param);
    }

    @Override
    public void updateExecuteAppend(ExecuteAppend param) throws SQLException {
        System.out.println(nameSpace + "updateExecuteAppend");
        sqlmap.update(nameSpace + "updateExecuteAppend", param);
    }

    @Override
    public void deleteExecBase(CateEditBase param) throws SQLException {
        System.out.println(nameSpace + "deleteExecBase");
        sqlmap.delete(nameSpace + "deleteExecBase", param);
    }

    @Override
    public void deleteExecDetail(CateEditDetail param) throws SQLException {
        System.out.println(nameSpace + "deleteExecDetail");
        sqlmap.delete(nameSpace + "deleteExecDetail", param);
    }

    @Override
    public void deleteExecuteAppend(ExecuteAppend param) throws SQLException {
        System.out.println(nameSpace + "deleteExecuteAppend");
        sqlmap.delete(nameSpace + "deleteExecuteAppend", param);
    }

    @Override
    public Integer queryMaxNumberFromExecBase(CateEditBase param) {
        System.out.println(nameSpace + "queryMaxNumberFromExecBase");
        try {
            return (Integer) sqlmap.queryForObject(nameSpace + "queryMaxNumberFromExecBase", param);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }

    @Override
    public Integer queryMaxNumberFromExecuteAppend(ExecuteAppend param) {
        System.out.println(nameSpace + "queryMaxNumberFromExecuteAppend");
        try {
            return (Integer) sqlmap.queryForObject(nameSpace + "queryMaxNumberFromExecuteAppend", param);
        } catch (SQLException ex) {
            Logger.getLogger(ProcureBudgetEditDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
}
